package com.example.springcloud.alibaba.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class CommonResult {
    private Integer code;
    private String msg;
    private Object data;

    public static CommonResult success(Object obj) {
        return new CommonResult(CommonResultEnum.SUCCESS.getCode(), CommonResultEnum.SUCCESS.getMessage(), obj);
    }

    public static CommonResult success() {
        return new CommonResult(CommonResultEnum.SUCCESS.getCode(), CommonResultEnum.SUCCESS.getMessage(), null);
    }

    public static CommonResult error(CommonResultEnum resultEnum) {
        return new CommonResult(resultEnum.getCode(), resultEnum.getMessage(), null);
    }

    public static CommonResult error(CommonResultEnum resultEnum, Object obj) {
        return new CommonResult(resultEnum.getCode(), resultEnum.getMessage(), obj);
    }
}
